# python -m project_root.api.api_operation_role
from .api_token import Token
from util.time_util import timestran
import requests
import pytest


class Api_Operation(Token):


    def get_list(self,role_name=''):
        url = 'http://hxzhan.rtcloud.com:32111/tm/roles/list'
        json = {
            'limit':10,
            'page':1,
            'role_name':role_name,
            'roles_type':1
        }
        response = requests.post(url=url,json=json,headers=self.get_header())
        values = []
        keys = ['role_name','role_remark','created_at']
        if response.json()['data']['list'] == None:
            return []
        else:
            for node in response.json()['data']['list']:
                for key in keys:
                    if key == 'created_at':
                        values.append(timestran(node[key]))
                    else:
                        values.append(node[key])
            return values
        
api = Api_Operation()
print(api.get_list('%'))